defining js code a bit down

Judy Ngai 9 年之前
父节点
当前提交
e86045cb0e
共有 1 个文件被更改,包括 9 次插入11 次删除
  1. 9 11
      app/assets/javascripts/pages/agent-show-page.js.coffee

+ 9 - 11
app/assets/javascripts/pages/agent-show-page.js.coffee

@@ -1,10 +1,5 @@
1 1
 class @AgentShowPage
2 2
   constructor: ->
3
-    $('#toggle-memory').click ->
4
-      if $('#memorypanel').hasClass('hidden')
5
-        $('#memorypanel').removeClass 'hidden'
6
-      else
7
-        $('#memorypanel').addClass 'hidden'
8 3
 
9 4
     $(".agent-show #show-tabs a[href='#logs'], #logs .refresh").on "click", @fetchLogs
10 5
     $(".agent-show #logs .clear").on "click", @clearLogs
@@ -15,6 +10,12 @@ class @AgentShowPage
15 10
       if tab in ["details", "logs"]
16 11
         $(".agent-show .nav-pills li a[href='##{tab}']").click()
17 12
 
13
+    $('#toggle-memory').click ->
14
+      if $('#memorypanel').hasClass('hidden')
15
+        $('#memorypanel').removeClass 'hidden'
16
+      else
17
+        $('#memorypanel').addClass 'hidden'
18
+
18 19
   fetchLogs: (e) ->
19 20
     agentId = $(e.target).closest("[data-agent-id]").data("agent-id")
20 21
     e.preventDefault()
@@ -47,6 +48,7 @@ class @AgentShowPage
47 48
           $("#logs .refresh, #logs .clear").show()
48 49
 
49 50
   clearMemory: (e) ->
51
+
50 52
     if confirm("Are you sure you want to clear memory of this Agent?")
51 53
       agentId = $(e.target).closest("[data-agent-id]").data("agent-id")
52 54
       e.preventDefault()
@@ -59,12 +61,8 @@ class @AgentShowPage
59 61
         .fail ->
60 62
           $("#memory .spinner").fadeOut ->
61 63
             $("#memory .clear").css(display: 'inline-block')
62
-
63
-    $('#toggle-memory').click ->
64
-      if $('#memorypanel').hasClass('hidden')
65
-        $('#memorypanel').removeClass 'hidden'
66
-      else
67
-        $('#memorypanel').addClass 'hidden'
64
+            
68 65
 
69 66
 $ ->
70 67
   Utils.registerPage(AgentShowPage, forPathsMatching: /^agents\/\d+/)
68
+